package com.ruoyi.school.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.school.domain.School;
import com.ruoyi.school.mapper.SchoolMapper;
import com.ruoyi.school.service.ISchoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 学校管理Service业务层处理
 *
 * @author ruoyi
 * @date 2024-10-17
 */
@Service
public class SchoolServiceImpl extends ServiceImpl<SchoolMapper, School>
        implements ISchoolService {
    @Autowired
    private SchoolMapper schoolMapper;

    /**
     * 查询学校管理
     *
     * @param id 学校管理主键
     * @return 学校管理
     */
    @Override
    public School selectSchoolById(Long id) {
        return schoolMapper.selectSchoolById(id);
    }

    /**
     * 查询学校管理列表
     *
     * @param school 学校管理
     * @return 学校管理
     */
    @Override
    public List<School> selectSchoolList(School school) {
        return schoolMapper.selectSchoolList(school);
    }

    /**
     * 新增学校管理
     *
     * @param school 学校管理
     * @return 结果
     */
    @Override
    public int insertSchool(School school) {
        school.setCreateTime(DateUtils.getNowDate());
        return schoolMapper.insertSchool(school);
    }

    /**
     * 修改学校管理
     *
     * @param school 学校管理
     * @return 结果
     */
    @Override
    public int updateSchool(School school) {
        school.setUpdateTime(DateUtils.getNowDate());
        return schoolMapper.updateSchool(school);
    }

    /**
     * 批量删除学校管理
     *
     * @param ids 需要删除的学校管理主键
     * @return 结果
     */
    @Override
    public int deleteSchoolByIds(Long[] ids) {
        return schoolMapper.deleteSchoolByIds(ids);
    }

    /**
     * 删除学校管理信息
     *
     * @param id 学校管理主键
     * @return 结果
     */
    @Override
    public int deleteSchoolById(Long id) {
        return schoolMapper.deleteSchoolById(id);
    }

    /**
     * 按条件获取单个
     */
    @Override
    public School selectSchoolOne(School school) {
        System.out.println("111111");
        System.out.println(school);
        School re = schoolMapper.selectOne(new LambdaQueryWrapper<School>().eq(School::getSchoolName, school.getSchoolName()));
        System.out.println("111111111");
        System.out.println(re);
        return re;
    }
}
